package JavaTest02.java;

import java.util.Scanner;

public class Household {
    public static void main(String[] args) {

        double balance=0;
        Scanner scanner=new Scanner(System.in);

      while (true){
          System.out.println("========================");
          System.out.println("========家庭收支记录=======");
          System.out.println("========1.收入明细========");
          System.out.println("========2.登记收入========");
          System.out.println("========3.登记支出========");
          System.out.println("========4.退   出========");
          System.out.println("请选择（1——4）" );
          System.out.println("========================");
          int choice=scanner.nextInt();//输入值

          switch (choice){

              case 1:
                  System.out.println("1.收入明细"+balance);
                  break;

              case 2:
                  System.out.println("2.登记收入");
                  System.out.println("本次收入金额为：");
                  double amount=scanner.nextDouble();
                  if (amount>0){
                      balance+=amount;
                      String sm=scanner.nextLine();
                      System.out.println("本次收入说明为："+sm);
              }
                  break;

              case 3:
                  System.out.println("3.支出登记");
                  System.out.println("请输入支出金额：");
                  double Amount=scanner.nextDouble();
                  if (Amount>0 && Amount<=balance){
                      balance-=Amount;
                      String  zcsm=scanner.nextLine();
                      System.out.println("本次支出说明为："+ zcsm);
                  }

                  break;


              case 4:
                  System.out.println("退出");
                  System.out.println("感谢使用，再见");
                  System.exit(0);
                  break;

              default:
                  System.out.println("请选择（1——4）");
          }
      }
    }
}
